var a = require("../../../../@babel/runtime/helpers/typeof"), t = getApp();

Page({
    data: {
        language: "",
        activeName: "first",
        first_content: [],
        amountTotal: "0.00",
        team_level: "",
        loading: !1,
        allLoaded: !1,
        goload: !0,
        isLoadMore: !0,
        page: 1,
        total_page: 0,
        custom_name: ""
    },
    onLoad: function(a) {
        this.checkrouter(), this.getData(), this.getDividendList();
    },
    checkrouter: function() {
        try {
            var t = function() {
                for (var a = wx.getStorageSync("yz_basic_info"), t = a.popularize_page.mini.vue_route, e = 0; e < t.length; e++) if ("shareholder_dividend" == t[e]) return console.log(a.popularize_page.mini.mini_url + "跳转的路径"), 
                wx.showToast({
                    title: "未开启推广权限",
                    duration: 1e3,
                    icon: "none",
                    success: function() {
                        setTimeout(function() {
                            wx.redirectTo({
                                url: a.popularize_page.mini.mini_url
                            });
                        }, 1e3);
                    }
                }), {
                    v: void 0
                };
            }();
            if ("object" === a(t)) return t.v;
        } catch (a) {
            console.log(a);
        }
    },
    onReady: function() {
        var a = wx.getStorageSync("langIndex");
        this.setData({
            language: a.en
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {
        this.data.isLoadMore ? this.getMoreDividendListData() : wx.showToast({
            title: "没有更多了",
            icon: "none"
        });
    },
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    getData: function() {
        var a = this, e = t.getNetAddresss("plugin.shareholder-dividend.api.shareholder.get-shareholder-statistic");
        t._getNetWork({
            url: e,
            success: function(t) {
                var e = t.data;
                1 === e.result ? (a.setData({
                    amountTotal: e.data.amountTotal,
                    team_level: e.data.team_level,
                    capping: e.data.capping,
                    capping_money: e.data.capping_money ? e.data.capping_money : "",
                    custom_name: e.data.set.custom_name || "股东分红"
                }), wx.setNavigationBarTitle({
                    title: a.data.custom_name
                })) : wx.showToast({
                    title: e.msg,
                    icon: "none"
                });
            },
            fail: function(a) {
                console.log(a);
            }
        });
    },
    getDividendList: function() {
        var a = this, e = t.getNetAddresss("plugin.shareholder-dividend.api.shareholder.get-shareholder-log");
        e += "&page=" + this.data.page, t._getNetWork({
            url: e,
            success: function(t) {
                var e = t.data;
                1 === e.result ? a.setData({
                    first_content: e.data.data,
                    total_page: e.data.last_page
                }) : wx.showToast({
                    title: e.msg,
                    icon: "none"
                });
            },
            fail: function(a) {
                console.log(a);
            }
        });
    },
    getMoreDividendListData: function() {
        var a = this;
        if (this.data.page != this.data.total_page) if (this.data.page >= this.data.total_page) this.setData({
            loading: !0,
            allLoaded: !0
        }); else {
            var e = this.data.page + 1;
            this.setData({
                page: e
            });
            var o = t.getNetAddresss("plugin.shareholder-dividend.api.shareholder.get-shareholder-log");
            o += "&page=" + this.data.page, t._getNetWork({
                url: o,
                success: function(t) {
                    var e = t.data;
                    if (1 === e.result) {
                        var o = a.data.first_content.concat(e.data.data);
                        a.setData({
                            first_content: o,
                            loading: !1,
                            allLoaded: !1
                        });
                    } else {
                        var i = a.data.page - 1;
                        a.setData({
                            page: i,
                            loading: !0,
                            allLoaded: !0,
                            isLoadMore: !1
                        });
                    }
                },
                fail: function(a) {
                    console.log(a);
                }
            });
        }
    }
});